//
//  CydhThdView.m
//  上海杨浦
//
//  Created by FrankChen on 13-5-24.
//  Copyright (c) 2013年 FrankChen. All rights reserved.
//

#import "CydhThdView.h"

@implementation CydhThdView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        //[self setBackgroundColor:[UIColor grayColor]];
        //
        
        [self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgImg_cell.png"]]];
    }
    return self;
}


-(void) AddImageView:(int)flag{
    UIImageView *imageView=[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)]autorelease];
    [imageView setBackgroundColor:[UIColor blueColor]];
    [self AddLabel:imageView:flag];
    [self addSubview:imageView];
}

-(void) AddLabel:(UIImageView *)imageView :(int)flag{
    UILabel *label=[[[UILabel alloc]initWithFrame:CGRectMake(124, 1, 80, 28)]autorelease];
    UIFont *font=[UIFont fontWithName:@"FZHTJW--GB1-0" size:18.0f];
    [label setFont:font];
    [label setBackgroundColor:[UIColor blueColor]];
    [label setTextColor:[UIColor whiteColor]];
    switch (flag) {
        case 1:{
            [label setText:@"政府部门"];
            break;}
        case 2:{
            [label setText:@"街道、镇"];
            break;}
        case 3:{
            [label setText:@"事业单位"];
            break;}
        case 4:{
            [label setText:@"    其他"];
            break;}
    }
    [imageView addSubview:label];
}

-(void) AddBackBtn{
    UIButton *btn_back = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn_back setImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal];
    btn_back.frame = CGRectMake(15, 1, 72, 29);
    [btn_back addTarget:self action:@selector(Btn_Back_Clicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn_back];
}

-(void)Btn_Back_Clicked{
    [self removeFromSuperview];
}

-(UIWebView *)AddWebView{
    UIWebView *webView=[[[UIWebView alloc]initWithFrame:CGRectMake(0, 30, 320, 411)]autorelease];
    [webView setDataDetectorTypes:UIDataDetectorTypeNone];
    [self addSubview:webView];
    return webView;
}

-(void)showTeles:(int)flag{
    [self AddBackBtn];
    UIWebView *webView=[self AddWebView];
    
    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    
    NSString *url=[[[NSString alloc]init]autorelease];
    
    switch (flag) {
        case 1:{
            url=@"zgbm_tele.htm";
            break;}
        case 2:{
            url=@"jdz_tele.htm";
            break;}
        case 3:{
            url=@"sjdw_tele.htm";
            break;}
        case 4:{
            url=@"qt_tele.htm";
            break;}
    }
    NSString *filePath =[resourcePath stringByAppendingPathComponent:url];
    
    NSString *htmlstring=[[[NSString alloc] initWithContentsOfFile:filePath  encoding:NSUTF8StringEncoding error:nil]autorelease];
    [webView loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];
    
}


-(void)initData:(int)flag{
    [self AddImageView:flag];
    [self showTeles:flag];
}
@end





























